package com.hq.ims.data.vo;

import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.PermissionRole;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @since 20240920
 */
@Mapper
public interface PermissionRoleMapstruct {

    PermissionRoleMapstruct INSTANCE = Mappers.getMapper(PermissionRoleMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------


    @Mappings({
    })
    PermissionRoleVo toPermissionRoleVo(PermissionRole source);

    default List<PermissionRoleVo> toPermissionRoleVoList(List<PermissionRole> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toPermissionRoleVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class PermissionRoleVo extends PermissionRole {

        @ApiModelProperty("权限ID")
        private List<String> permissionAuthorityIdList;
    }

    @ApiModel(value = "只有角色ID和名称对象")
    @Data
    class PermissionRoleIdAndNameVo {

        @ApiModelProperty(value = "角色ID")
        private String permissionRoleId;

        @ApiModelProperty(value = "角色名称")
        private String permissionRoleName;

    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

        @ApiModelProperty(value = "角色名称")
        private String roleName;

        @ApiModelProperty(value = "公司ID")
        private String companyId;

        @ApiModelProperty(value = "组ID")
        private String permissionGroupId;

    }

    @ApiModel(value = "搜索VO")
    @Data
    class SaveVo {

        @NotBlank(message = "角色ID名称不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "角色ID")
        private String permissionRoleId;

        @NotBlank(message = "角色名称不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "角色名称")
        private String roleName;

        @NotBlank(message = "公司不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "公司ID")
        private String companyId;

        @NotBlank(message = "组Id不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "组ID")
        private String permissionGroupId;

    }

    //-------------------------------- 以下为自定义类[其它] --------------------------------


    //-------------------------------- springboot验证标识 --------------------------------

}
